from django.db import models

# Create your models here.
from django.db import models
from django.core.validators import MinValueValidator, \
    MaxValueValidator


class Coupon(models.Model):
    code = models.CharField('优惠劵编号',max_length=50,
                            unique=True)
    valid_from = models.DateTimeField('开始时间',)
    valid_to = models.DateTimeField('结束时间',)
    discount = models.IntegerField('折扣百分比（1-100）',
        validators=[MinValueValidator(0),
                    MaxValueValidator(100)])
    active = models.BooleanField('是否激活优惠',)

    def __str__(self):
        return self.code
    class Meta:
        verbose_name = '优惠劵'
        verbose_name_plural = '优惠劵管理'